const {
  resolve
} = require("path")
const merge = require("webpack-merge")
const { bases } = require("./webpack.base")
const UglifyJsPlugin = require("uglifyjs-webpack-plugin")
module.exports = merge(bases, {
  // webpack基于node构建的
  mode: "production", // production
  devtool: "cheap-module-source-map",
  entry: [`${process.cwd()}/src/index.js`],
  output: {
    filename: "main.js", // 通过热加载输出script文件挂载在目录与index.HTML一样
    path: resolve(process.cwd(), "dist")
  },
  optimization: {
    minimizer: [
      new UglifyJsPlugin({
        uglifyOptions: {
          output: {
            comments: false
          },
          compress: {
            drop_debugger: true,
            drop_console: true
          }
        }
      })
    ]
  },
  performance: {
    hints: "warning", // false关闭提示 下面设置就没必要了
    // 入口起点的最大体积
    maxEntrypointSize: 50000000,
    // 生成文件的最大体积
    maxAssetSize: 30000000,
    // 只给出 js 文件的性能提示
    assetFilter: function (assetFilename) {
      return assetFilename.endsWith(".js")
    }
  }
})
